<?
require_once("config.php");
if($myuser->logged()){
    redirect('/trang-ca-nhan/');
}
$action = getValue('action_log','str','POST','');
if($action == 'action_log'){
	$username			= getValue("email", "str", "POST", "", 1);
	$password			= getValue("password", "str", "POST", "", 1);
	$remember			= getValue("remember_me", "int", "POST", 0);
	if($remember 		==	 0){
		$time				=	time() + (1 * 86400);
	}else{
		$time				=	time() + (365 * 86400);
	}
	$myuser = new user($username, $password);
	
	$myuser->savecookie($time);

	if($myuser->logged() != 1){
		echo "<script>alert('Đăng nhập thất bại !','Thông báo',(setTimeout('window.location.reload()', 100)));</script>";
	}else{
      redirect('/trang-ca-nhan/');
	}
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="vi" lang="vi" xmlns:og="http://ogp.me/ns#" xmlns:fb="http://www.facebook.com/2008/fbml">
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>ID Sudo - Đăng nhập hệ thống</title>
    <!-- Core CSS - Include with every page -->
   <link href="/home_v2/css/bootstrap.min.css" rel="stylesheet">
   <link href="/home_v2/font-awesome/css/font-awesome.css" rel="stylesheet">
   <!-- Page-Level Plugin CSS - Dashboard -->
   <link href="/home_v2/css/plugins/morris/morris-0.4.3.min.css" rel="stylesheet">
   <link href="/home_v2/css/plugins/timeline/timeline.css" rel="stylesheet">
   <!-- SB Admin CSS - Include with every page -->
   <link href="/home_v2/css/sb-admin.css" rel="stylesheet">
   <link href="/home_v2/css/custom.css" rel="stylesheet">
   <link rel="stylesheet" href="/themes/css/datepicker.css"/>
   <!-- Core Scripts - Include with every page -->
   <script src="/home_v2/js/jquery-1.10.2.js"></script>
   <script src="/home_v2/js/bootstrap.min.js"></script>
   <script src="/home_v2/js/plugins/metisMenu/jquery.metisMenu.js"></script>
   <script type="text/javascript" src="/themes/js/sudo-datepicker.js"></script>
   <script type="text/javascript" src="/themes/js/common.js"></script>
</head>
<body>
    <div class="container">
        <div class="row">
            <div class="col-md-4 col-md-offset-4">
                <div class="login-panel panel panel-default">
                    <div class="panel-heading">
                        <h3 class="panel-title">Đăng nhập hệ thống</h3>
                    </div>
                    <div class="panel-body">
                        <form role="form" method="post" action="">
                           <input type="hidden" name="action_log" value="action_log" />
                            <fieldset>
                                <div class="form-group">
                                    <input class="form-control" placeholder="E-mail của bạn" name="email" type="email" autofocus>
                                </div>
                                <div class="form-group">
                                    <input class="form-control" placeholder="Password" name="password" type="password" value="">
                                </div>
                                <div class="checkbox">
                                    <label>
                                        <input name="remember_me" type="checkbox" value="Remember Me">Ghi nhớ trên máy tính
                                    </label>
                                </div>
                                <!-- Change this to a button or input when using this as a form -->
                                <input type="submit" name="commit" value="Đăng nhập" class="btn btn-lg btn-success btn-block">
                            </fieldset>
                        </form>
                    </div>
                </div>
            </div>
        </div>
      <div class="login-help">
         <p>Quên mật khẩu ? <a href="/quen-mat-khau.html">Click vào để lấy lại mật khẩu</a>.</p>
         <p>Chưa có tài khoản ? <a href="/dang-ky.html">Click vào để đăng ký tài khoản</a>.</p>
       </div>
    </div>
    <!-- Core Scripts - Include with every page -->
    <script src="js/jquery-1.10.2.js"></script>
    <script src="js/bootstrap.min.js"></script>
    <script src="js/plugins/metisMenu/jquery.metisMenu.js"></script>
    <!-- SB Admin Scripts - Include with every page -->
    <script src="js/sb-admin.js"></script>
</body>
</html>
